import 'dart:convert';

import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:yysk_app/utils/colors.dart';
import 'package:yysk_app/utils/helper.dart';
import 'package:yysk_app/utils/js_tool.dart';
import 'package:yysk_app/widget/bank_pick_widget.dart';
import 'package:yysk_app/widget/button_widget.dart';
import 'package:yysk_app/widget/drop_down_widget.dart';
import 'package:yysk_app/widget/id_validity_picker_widget.dart';
import 'package:yysk_app/widget/image_asset_widget.dart';
import 'package:yysk_app/widget/lazy_network_image.dart';
import 'package:yysk_app/widget/region_pick_widget.dart';
import '../../../../widget/checkbox_widget.dart';
import 'enterprise_auth_zhifu_controller.dart';
import 'package:yysk_app/widget/custom_app_bar2.dart';

class EnterpriseAuthZhifuPage extends GetView<EnterpriseAuthZhifuController> {
  static const path = '/enterpriseAuthZhifu';
  const EnterpriseAuthZhifuPage({super.key});

  @override
  Widget build(BuildContext context) {
    final double top = MediaQuery.of(context).padding.top;
  
    return Scaffold(
      body: SafeArea(top: false,child: Stack(
        children: [
          //添加背景色，代码如下：
          SizedBox(
            width: context.width,
            child: ImageAssetWidget(
              width: double.infinity,
              height: 173.px,
              imageUrl: 'static/images/wallet/top_bg.png',
            ),
          ),
          Padding(
            padding: EdgeInsets.fromLTRB(0, top, 0, 0.px),
            child: Column(
              children: [
                CustomAppBar2(title: '企业认证', context: context),
                Expanded(
                  child: Obx(
                        () => SingleChildScrollView(
                      padding: EdgeInsets.fromLTRB(17.px, 14.px, 14.px, 20.px),
                      child: Column(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        children: [
                          Text('${controller.test.value}',style: TextStyle(fontSize: 0),),
                          DropDownWidget(
                            dataList: controller.companyList,
                            type: '',
                            initialSelection:controller.openWalletInfo.value.plat!,
                            onPress: (e) {
                              controller.openWalletInfo.value.plat = e;
                              controller.openWalletInfo.value.bankAccount?.accountType = '';
                              controller.type.value =  e;
                              if(e == ''){
                                controller.chooseType.value = '';
                              }
                              controller.test.value++;

                            },
                          ),
                          SizedBox(height: 43.px),
                          _inputItem(
                            '企业法人',
                            '请输入姓名',
                            controller.infoDetail.value?.name ?? '',
                          ),
                          _inputItem(
                            '身份证',
                            '请输入姓名',
                            controller.infoDetail.value?.cardId ?? '',
                          ),
                          _label('企业/商户名称'),
                          _readonlyOrInput(
                              controller: controller.companyNameController,
                              hint: '请输入公司名称',
                              type: 'signName',
                              isAuthed: controller.isAuthed.value
                          ),
                          SizedBox(height: 25.px),
                          _label('统一社会信用代码'),
                          _readonlyOrInput(
                              controller: controller.creditCodeController,
                              hint: '请输入信用代码',
                              type: 'certNo',
                              isAuthed: controller.isAuthed.value
                          ),
                          SizedBox(height: 25.px),
                          Text(
                            '证件期限类型',
                            style: TextStyle(
                              color:  AppColors.fontColorBlack,
                              fontSize: 16.px,
                              // fontWeight: FontWeight.bold,
                              fontFamily: 'CustomPINGFANG',
                            ),
                          ),
                          _buildCartTypeTime(
                            context: context,
                            OpenWalletController: controller,
                          ),
                          SizedBox(height: 16.px),
                          Text(
                            '证件有效期',
                            style: TextStyle(
                              color:  AppColors.fontColorBlack,
                              fontSize: 16.px,
                              // fontWeight: FontWeight.bold,
                              fontFamily: 'CustomPINGFANG',
                            ),
                          ),
                          _buildCartType(
                            context: context,
                            OpenWalletController: controller,
                          ),
                          SizedBox(height: 25.px),
                          _label('公司地址'),
                          _addressWidget(
                            context: context,
                            level: 3,
                            type: 'companyAddress',
                            controller: controller,
                          ),
                          SizedBox(height: 25.px),
                          _label('详细公司地址'),
                          _readonlyOrInput(
                              controller: controller.detailAddressController,
                              hint: '请输入公司详细地址',
                              type: 'address',
                              isAuthed: controller.isAuthed.value
                          ),
                          SizedBox(height: 25.px),
                          _label('账户类型'),
                          DropDownWidget(
                            initialSelection:controller.openWalletInfo.value.bankAccount!.accountType!,
                            dataList:
                            controller.type.value ==
                                'ENTERPRISE' ? [
                              ChooseTypeModel(name: '请选择', type: ''),
                              ChooseTypeModel(
                                name: '对公',
                                type: 'CORPORATE',
                              ),
                            ] : (controller.openWalletInfo.value.plat ==
                                'INDIVIDUAL_BUSINESS'
                                ? [
                              ChooseTypeModel(
                                name: '请选择',
                                type: '',
                              ),
                              ChooseTypeModel(
                                name: '对公',
                                type: 'CORPORATE',
                              ),
                              ChooseTypeModel(
                                name: '对私',
                                type: 'PERSONAL',
                              ),
                            ]
                                : [
                              ChooseTypeModel(
                                name: '请选择',
                                type: '',
                              ),
                            ]),
                            type: '',
                            style: 'pro',
                            onPress: (e) {
                              controller.openWalletInfo.value.bankAccount!.accountType = e;
                              controller.chooseType.value = e.toString();
                              controller.test.value++;
                            },
                          ),
                          SizedBox(height: 25.px),
                          _label('绑定银行卡号'),
                          _readonlyOrInput(
                              controller: controller.bankCardController,
                              hint: '请输入银行卡号',
                              type: 'cardNo',
                              isAuthed: controller.isAuthed.value
                          ),
                          Visibility(
                              visible: controller.chooseType.value == 'PERSONAL',
                              child: Column(
                                crossAxisAlignment: CrossAxisAlignment.start,
                                children: [
                                  SizedBox(height: 25.px),
                                  _label('手机号'),
                                  _readonlyOrInput(
                                      controller: controller.phoneController,
                                      hint: '${(controller.infoDetail.value?.userTel == null || controller.infoDetail.value?.userTel == '') ? '请输入银行卡预留手机号' : controller.infoDetail.value!.userTel}',
                                      type: 'legalPersonMobile',
                                      isAuthed: controller.isAuthed.value
                                  ),
                                ],
                              )
                          ),
                          Visibility(
                              visible: controller.chooseType.value == 'CORPORATE',
                              child: Column(
                                crossAxisAlignment: CrossAxisAlignment.start,
                                children: [
                                  SizedBox(height: 25.px),
                                  _label('开户许可证号'),
                                  _readonlyOrInput(
                                      controller: controller.licenceCodeController,
                                      hint: '请输入开户许可证号',
                                      type: 'certNo',
                                      isAuthed: controller.isAuthed.value
                                  ),
                                ],
                              )
                          ),
                          SizedBox(height: 25.px),
                          _label('联系人'),
                          _readonlyOrInput(
                              controller: controller.phoneContectController,
                              hint: '请输入联系人',
                              type: 'contactMobile',
                              isAuthed: controller.isAuthed.value
                          ),
                          SizedBox(height: 25.px),
                          _label('联系人电话'),
                          _readonlyOrInput(
                              controller: controller.phoneNumberContectController,
                              hint: '请输入联系人电话',
                              type: 'contactMobile',
                              isAuthed: controller.isAuthed.value
                          ),
                          SizedBox(height: 25.px),
                          _label('联系人邮箱'),
                          _readonlyOrInput(
                              controller: controller.mailboxContectController,
                              hint: '请输入联系人邮箱',
                              type: 'contactMobile',
                              isAuthed: controller.isAuthed.value
                          ),


                          SizedBox(height: 32.px),
                          if (!controller.isAuthed.value)
                            ButtonWidget(
                              label: '提交认证',
                              height: 54.px,
                              width: 322.px,
                              fontSize: 18.px,
                              imageBg: 'static/images/btm.png',
                              contentType: ContentType.other,
                              onPressed: controller.submitAuth,
                            ),

                          // SizedBox(
                          //   width: double.infinity,
                          //   height: 48,
                          //   child: ElevatedButton(
                          //     onPressed: controller.submitAuth,
                          //     style: ElevatedButton.styleFrom(
                          //       backgroundColor: const Color(0xFFB2E9E2),
                          //       shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(24)),
                          //     ),
                          //     child: controller.loading.value
                          //       ? const CircularProgressIndicator(color: Colors.white)
                          //       : const Text('提交认证', style: TextStyle(fontSize: 18, color: Color(0xFF6CBF3C))),
                          //   ),
                          // ),
                        ],
                      ),
                    ),
                  ),
                ),
              ],
            ),
          ),
        ],
      )),
    );
  }

  _idCardItem({
    required BuildContext context,
    required EnterpriseAuthZhifuController controller,
    bool isAuthed = false
  }) {
    return Obx(
      () => Container(
        child: Row(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: [
            Column(
              children: [
                GestureDetector(
                  onTap: () {
                    if(isAuthed){
                      return;
                    }
                    controller.uploadImage('4');
                  },
                  child: SizedBox(
                    width: 160.px,
                    height: 105.px,
                    child:
                        controller
                                    .openWalletInfo
                                    .value
                                    .legalPersonInfo
                                    ?.legalLicenceFrontUrl ==
                                ''
                            ? ImageAssetWidget(
                              imageUrl: 'static/images/wallet/id_card_2.png',
                              width: 160.px,
                              height: 105.px,
                            )
                            : LazyImage(
                              imageUrl:
                                  controller
                                      .openWalletInfo
                                      .value
                                      .legalPersonInfo
                                      ?.legalLicenceFrontUrl ??
                                  '',
                              width: 160.px,
                              height: 105.px,
                            ),
                  ),
                ),
                SizedBox(height: 11.px),
                Center(
                  child: Text(
                    '+ 点击上传身份证人像面',
                    style: TextStyle(
                      fontSize: 12.px,
                      color: AppColors.fontColorBlack,
                    ),
                  ),
                ),
              ],
            ),
            Column(
              children: [
                GestureDetector(
                  onTap: () {
                      if(isAuthed){
                      return;
                    }
                    controller.uploadImage('3');
                  },
                  child: Container(
                    width: 160.px,
                    height: 105.px,
                    child:
                        controller
                                    .openWalletInfo
                                    .value
                                    .legalPersonInfo
                                    ?.legalLicenceBacktUrl ==
                                ''
                            ? ImageAssetWidget(
                              imageUrl: 'static/images/wallet/id_card_1.png',
                              width: 160.px,
                              height: 105.px,
                            )
                            : LazyImage(
                              imageUrl:
                                  controller
                                      .openWalletInfo
                                      .value
                                      .legalPersonInfo
                                      ?.legalLicenceBacktUrl ??
                                  '',
                              width: 160.px,
                              height: 105.px,
                            ),
                  ),
                ),

                SizedBox(height: 11.px),
                Center(
                  child: Text(
                    '+ 点击上传身份证国徽面',
                    style: TextStyle(
                      fontSize: 12.px,
                      color: AppColors.fontColorBlack,
                    ),
                  ),
                ),
              ],
            ),
          ],
        ),
      ),
    );
  }

  Widget _inputItem(String label, String hint, String value) {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Text(label, style: TextStyle(color: Colors.black45, fontSize: 16.px)),
        SizedBox(height: 20.px),
        Text(
          value,
          style: TextStyle(color: AppColors.fontColorBlack, fontSize: 16.px),
        ),
        SizedBox(height: 9.px),
        Container(
          width: 344.px,
          height: 1.px,
          color: AppColors.backgroundColorGreyF2,
        ),
        SizedBox(height: 30.px),
      ],
    );
  }

  Widget _label(String text) => Padding(
    padding: EdgeInsets.only(bottom: 15.px),
    child: Text(text, style: TextStyle(fontSize: 14.px, color: Colors.black87)),
  );

  Widget _readonlyOrInput({
    required TextEditingController controller,
    bool readonly = false,
    String? hint,
    required String? type,
     bool? isAuthed = false
  }) {
    return TextField(
      controller: controller,
      enabled:isAuthed==true?false: (readonly==false?true:false),
      decoration: InputDecoration(
        hintText: hint,
        filled: true,

        fillColor: const Color(0xFFF7F7F7),
        border: OutlineInputBorder(
          borderRadius: BorderRadius.circular(12),
          borderSide: BorderSide.none,
        ),
        contentPadding: const EdgeInsets.symmetric(
          horizontal: 16,
          vertical: 12,
        ),
      ),
      style: const TextStyle(fontSize: 16),
      onChanged:
          (value) => {consoleLog('${value}======value${controller.text}')},
    );
  }
  _buildCartTypeTime({
    required BuildContext context,
    required EnterpriseAuthZhifuController OpenWalletController,
  }) {
    return Obx(
          () => Container(
        width: context.width,
        height: 45.px,
        decoration: BoxDecoration(
          border: Border(
            bottom: BorderSide(
              width: 1.px,
              color: Color.fromRGBO(242, 242, 242, 1),
            ),
          ),
        ),
        child: Row(
          mainAxisAlignment: MainAxisAlignment.start,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            Container(
              child: Row(
                children: [
                  CheckboxWidget(
                    checked: !controller.isLongTerm.value,
                    size: 12.px,
                    onChanged: (value) {
                      controller.isLongTerm.value = false;
                      controller.certEndDate.value = '';
                    },
                  ),
                  Text(
                    '非长期有效',
                    style: TextStyle(
                      fontSize: 16.px,
                      color: AppColors.fontColorBlack,
                      fontFamily: 'CustomPINGFANG',
                    ),
                  ),
                ],
              ),
            ),
            SizedBox(width: 28.px),
            Container(
              child: Row(
                children: [
                  CheckboxWidget(
                    checked: controller.isLongTerm.value,
                    size: 12.px,
                    onChanged: (value) {
                      controller.isLongTerm.value = true;
                      controller.certEndDate.value = '20990101';
                    },
                  ),
                  Text(
                    '长期有效',
                    style: TextStyle(
                      fontSize: 16.px,
                      color: AppColors.fontColorBlack,
                      fontFamily: 'CustomPINGFANG',
                    ),
                  ),
                ],
              ),
            ),
          ],
        ),
      ),
    );
  }

  _buildCartType({
    required BuildContext context,
    required EnterpriseAuthZhifuController OpenWalletController
  }) {
    return Container(
      width: context.width,
      height: 45.px,
      decoration: BoxDecoration(
        border: Border(
          bottom: BorderSide(
            width: 1.px,
            color: Color.fromRGBO(242, 242, 242, 1),
          ),
        ),
      ),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.start,
        crossAxisAlignment: CrossAxisAlignment.center,
        children: [
          controller.certBeginDate.value==''? GestureDetector(
            onTap: (){
              controller.pickValidityDate(0);
            },
            child: Text(
              '起始时间',
              style: TextStyle(
                fontSize: 16.px,
                color: AppColors.fontColorGreenA9,
                fontFamily: 'CustomPINGFANG',
              ),
            ),
          ): GestureDetector(
            onTap: (){

              controller.pickValidityDate(0);
            },
            child: Text(
              controller.certBeginDate.value,
              style: TextStyle(
                fontSize: 16.px,
                color: AppColors.fontColorBlack,
                fontFamily: 'CustomPINGFANG',
              ),
            ),
          ),
          Text(
            '   -    ',
            style: TextStyle(
              fontSize: 16.px,
              color: AppColors.fontColorGreenA9,
              fontFamily: 'CustomPINGFANG',
            ),
          ),
          controller.certEndDate.value==''?GestureDetector(
            onTap: (){
              if(controller.isLongTerm.value==true){
                return;
              }
              controller.pickValidityDate(1);
            },
            child: Text(
              '截止日期',
              style: TextStyle(
                fontSize: 16.px,
                color: AppColors.fontColorGreenA9,
                fontFamily: 'CustomPINGFANG',
              ),
            ),
          ):GestureDetector(
            onTap: (){
              if(controller.isLongTerm.value==true){
                return;
              }
              controller.pickValidityDate(1);
            },
            child: Text(
              controller.certEndDate.value,
              style: TextStyle(
                fontSize: 16.px,
                color: AppColors.fontColorBlack,
                fontFamily: 'CustomPINGFANG',
              ),
            ),
          ),
        ],
      ),
    );
  }

  Widget _licenseWidget({
    required BuildContext context,
    required String url,
    required String type,
    required EnterpriseAuthZhifuController controller,
    String txt = '+ 点击上传营业执照',
    bool? isAuthed = false
  }) {
    return GestureDetector(
      onTap: () {
        if(isAuthed==true){
          return;
        }
        controller.uploadImage(type);
      },
      child: Container(
        width: double.infinity,
        // height: 120,
        decoration: BoxDecoration(
          color: const Color(0xFFF7F7F7),
          borderRadius: BorderRadius.circular(16),
          border: Border.all(
            color: const Color(0xFFE6E6E6),
            style: BorderStyle.solid,
          ),
        ),
        child:
            url == ""
                ? Column(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: [
                    SizedBox(height: 22.px),
                    ImageAssetWidget(
                      imageUrl: "static/images/wallet/yingyezhizhao.png",
                      width: 188.px,
                      height: 125.px,
                    ),
                    SizedBox(height: 8),
                    Text(
                      txt,
                      style: TextStyle(
                        color: AppColors.fontColorBlack,
                        fontSize: 16.px,
                      ),
                    ),
                    SizedBox(height: 20.px),
                  ],
                )
                : ClipRRect(
                  borderRadius: BorderRadius.circular(12),
                  child: LazyImage(
                    imageUrl: url,
                    boxFit: BoxFit.cover,
                    height: 197.px,
                    width: double.infinity,
                  ),
                ),
      ),
    );
  }

  // Widget _validityWidget(BuildContext context) {
  //   return Row(
  //     children: [
  //       Expanded(
  //         child: GestureDetector(
  //           onTap:
  //               controller.isAuthed.value ? null : controller.pickValidityDate,
  //           child: AbsorbPointer(
  //             child: TextField(
  //               controller: controller.validityController,
  //               enabled: false,
  //               decoration: InputDecoration(
  //                 hintText: '请选择证件有效期',
  //                 filled: true,
  //                 fillColor: const Color(0xFFF7F7F7),
  //                 border: OutlineInputBorder(
  //                   borderRadius: BorderRadius.circular(12),
  //                   borderSide: BorderSide.none,
  //                 ),
  //                 contentPadding: const EdgeInsets.symmetric(
  //                   horizontal: 16,
  //                   vertical: 12,
  //                 ),
  //               ),
  //               style: const TextStyle(fontSize: 16),
  //             ),
  //           ),
  //         ),
  //       ),
  //       const SizedBox(width: 12),
  //       Row(
  //         children: [
  //           Checkbox(
  //             value: controller.isLongTerm.value,
  //             onChanged:
  //                 controller.isAuthed.value
  //                     ? null
  //                     : (v) => controller.setLongTerm(v!),
  //           ),
  //           const Text('长期'),
  //         ],
  //       ),
  //     ],
  //   );
  // }

  Widget _addressWidget({
    required BuildContext context,
    int level = 2,
    String type = 'companyAddress',
    required EnterpriseAuthZhifuController controller,
  }) {
    //  companyAddress选择公司地址   bankAddress遗憾地址
    return Obx(
      () => GestureDetector(
        onTap: () {
          //  controller.isAuthed.value ? null : controller.pickAddress;
          //选择银行卡
          // _openBankPicker(context);
          _openCityPicker(
            context: context,
            level: level,
            type: type,
            controller: controller,
          );
          // showIDValidityPicker(context);
        },
        child: Container(
          padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 12),
          decoration: BoxDecoration(
            color: const Color(0xFFF7F7F7),
            borderRadius: BorderRadius.circular(12),
          ),
          child: Row(
            children: [
              Expanded(
                child: Text(
                  type == 'companyAddress'
                      ? (controller
                                  .openWalletInfo
                                  .value
                                  .businessAddressInfo
                                  ?.province !=
                              ''
                          ? '${controller.openWalletInfo.value.businessAddressInfo?.province},${controller.openWalletInfo.value.businessAddressInfo?.province},${controller.openWalletInfo.value.businessAddressInfo?.district}'
                          : '请选择省市区')
                      : (controller
                                  .openWalletInfo
                                  .value
                                  .bankAccount
                                  ?.province !=
                              ''
                          ? '${controller.openWalletInfo.value.bankAccount?.province},${controller.openWalletInfo.value.bankAccount?.city}'
                          : '请选择省市'),
                  style: TextStyle(
                    fontSize: 16,
                    color:
                        controller.addressText.value.isEmpty
                            ? Colors.black26
                            : Colors.black87,
                  ),
                ),
              ),
              const Icon(Icons.keyboard_arrow_right, color: Colors.black38),
            ],
          ),
        ),
      ),
    );
  }

  _bankChoose({
    required BuildContext context,
    required EnterpriseAuthZhifuController controller,
  }) {
    return Obx(
      () => GestureDetector(
        onTap: () {
          //  controller.isAuthed.value ? null : controller.pickAddress;
          //选择银行卡
          _openBankPicker(context);
          // _openCityPicker(context: context,level: level,type:type,controller:controller);
          // showIDValidityPicker(context);
        },
        child: Container(
          padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 12),
          decoration: BoxDecoration(
            color: const Color(0xFFF7F7F7),
            borderRadius: BorderRadius.circular(12),
          ),
          child: Row(
            children: [
              Expanded(
                child: Text(
                  controller.openWalletInfo.value.bankAccount?.bankName == ''
                      ? '选择银行'
                      : '${controller.openWalletInfo.value.bankAccount?.bankName}',
                  style: TextStyle(
                    fontSize: 16,
                    color:
                        controller.addressText.value.isEmpty
                            ? Colors.black26
                            : Colors.black87,
                  ),
                ),
              ),
              const Icon(Icons.keyboard_arrow_right, color: Colors.black38),
            ],
          ),
        ),
      ),
    );
  }

  // 打开银行选择器
  Future<void> _openBankPicker(BuildContext context) async {
    final result = await showModalBottomSheet<Map<String, String?>>(
      context: context,
      isScrollControlled: true,
      backgroundColor: Colors.transparent,
      builder:
          (context) => BankPicker(
            banks: controller.banks,
            initialBank: controller.openWalletInfo.value.bankAccount?.bankName,
            initialBankCode:
                controller.openWalletInfo.value.bankAccount?.bankCode,
          ),
    );
    if (result != null) {
      controller.openWalletInfo.value.bankAccount?.bankName =
          result['selectedBank']!;
      controller.openWalletInfo.value.bankAccount?.bankCode =
          result['selectedCode']!;
    }
    controller.test.value++;
  }

  // 打开地址选择器
  Future<void> _openCityPicker({
    required BuildContext context,
    int level = 3,
    required EnterpriseAuthZhifuController controller,
    String type = 'companyAddress', //  companyAddress选择公司地址   bankAddress遗憾地址
  }) async {
    showModalBottomSheet<Map<String, String?>>(
      context: context,
      builder:
          (context) => RegionPicker(
            callback: (LevelModel e) {
              consoleLog('省=${e.province}市=${e.city}=区=${e.district}');
              if (type == 'companyAddress') {
                controller.openWalletInfo.value.businessAddressInfo?.province =
                    e.province;
                controller.openWalletInfo.value.businessAddressInfo?.city =
                    e.city;
                controller.openWalletInfo.value.businessAddressInfo?.district =
                    e.district;
              } else if (type == 'bankAddress') {
                controller.openWalletInfo.value.bankAccount?.province =
                    e.province;
                controller.openWalletInfo.value.bankAccount?.city = e.city;
              }
              controller.test.value++;
            },
            level: level,
            provinces: controller.city, // 必需：地区数据
            // initialProvince: '北京市',       // 可选：初始选中的省份
            // initialCity: '北京市',           // 可选：初始选中的城市
            // initialDistrict: '朝阳区',       // 可选：初始选中的区县
          ),
    );
  }

  void showIDValidityPicker(BuildContext context) {
    final List<String> validityOptions = [
      '长期有效',
      '1 年',
      '2 年',
      '5 年',
      '10 年',
      '15 年',
    ];
    final String? initialValidity = '长期有效';
    final String? initialCode = 'long';

    showDialog(
      context: context,
      builder:
          (context) => IDValidityPicker(
            validityOptions: validityOptions,
            initialValidity: initialValidity,
            initialValidityCode: initialCode,
          ),
    );
  }
}
